﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.IO;

namespace Com.FoxGlobal.Daniel.Midea.TemplateService
{
    /// <summary>
    /// Summary description for WebServiceBase
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WebServiceBase : System.Web.Services.WebService
    {

        [WebMethod]
        public String StartSession()
        {
            try
            {
                string sessionid = Guid.NewGuid().ToString();
                string path = Server.MapPath("data\\" + sessionid);
                if (Directory.Exists(path))
                {
                    EndSession(sessionid);
                }


                Directory.CreateDirectory(path);
                return sessionid;

            }
            catch (Exception)
            {
                return "";
            }

        }

        [WebMethod]
        public void EndSession(String SessionID)
        {
            try
            {
                string path = Server.MapPath("data\\" + SessionID);
                if (Directory.Exists(path))
                {
                    Directory.Delete(path);
                }
            }
            catch (Exception)
            {

            }
        }


       
    }
}
